package cn.pms.po;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * Date entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "t_date", schema = "SCOTT")
public class Date implements java.io.Serializable
{
	private static final long serialVersionUID = 6902879659480399688L;
	// Fields
	private Integer id;
	private WorkTime workTime;
	private Month month;
	private Boolean isWork;
	private java.util.Date date;
	private String remark;
	private Set<Message> messagesForBeginDateId = new HashSet<Message>(0);
	private Set<Message> messagesForDateId = new HashSet<Message>(0);
	private Set<Message> messagesForEndDateId = new HashSet<Message>(0);
	private Set<Check> checks = new HashSet<Check>(0);
	
	// Constructors
	/** default constructor */
	public Date()
	{}
	
	/** minimal constructor */
	public Date(WorkTime workTime, Month month, Boolean isWork,
			java.util.Date date)
	{
		this.workTime = workTime;
		this.month = month;
		this.isWork = isWork;
		this.date = date;
	}
	
	/** full constructor */
	public Date(WorkTime workTime, Month month, Boolean isWork,
			java.util.Date date, String remark,
			Set<Message> messagesForBeginDateId,
			Set<Message> messagesForDateId, Set<Message> messagesForEndDateId,
			Set<Check> checks)
	{
		this.workTime = workTime;
		this.month = month;
		this.isWork = isWork;
		this.date = date;
		this.remark = remark;
		this.messagesForBeginDateId = messagesForBeginDateId;
		this.messagesForDateId = messagesForDateId;
		this.messagesForEndDateId = messagesForEndDateId;
		this.checks = checks;
	}
	
	// Property accessors
	@Id
	@Column(name = "id", unique = true, nullable = false, precision = 32, scale = 0)
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "SEQ_DATE")
	@SequenceGenerator(name = "SEQ_DATE", sequenceName = "SEQ_DATE", allocationSize = 1)
	public Integer getId()
	{
		return this.id;
	}
	
	public void setId(Integer id)
	{
		this.id = id;
	}
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "workTimeId", nullable = false)
	public WorkTime getWorkTime()
	{
		return this.workTime;
	}
	
	public void setWorkTime(WorkTime workTime)
	{
		this.workTime = workTime;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "monthId", nullable = false)
	public Month getMonth()
	{
		return this.month;
	}
	
	public void setMonth(Month month)
	{
		this.month = month;
	}
	
	@Temporal(TemporalType.DATE)
	@Column(name = "date", nullable = false, length = 7)
	public java.util.Date getDate()
	{
		return this.date;
	}
	
	@Column(name = "isWork", nullable = false)
	public void setIsWork(Boolean isWork)
	{
		this.isWork = isWork;
	}
	
	public Boolean getIsWork()
	{
		return isWork;
	}
	
	public void setDate(java.util.Date date)
	{
		this.date = date;
	}
	
	@Column(name = "remark", length = 500)
	public String getRemark()
	{
		return this.remark;
	}
	
	public void setRemark(String remark)
	{
		this.remark = remark;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "dateByBeginDateId")
	public Set<Message> getMessagesForBeginDateId()
	{
		return this.messagesForBeginDateId;
	}
	
	public void setMessagesForBeginDateId(Set<Message> messagesForBeginDateId)
	{
		this.messagesForBeginDateId = messagesForBeginDateId;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "dateByDateId")
	public Set<Message> getMessagesForDateId()
	{
		return this.messagesForDateId;
	}
	
	public void setMessagesForDateId(Set<Message> messagesForDateId)
	{
		this.messagesForDateId = messagesForDateId;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "dateByEndDateId")
	public Set<Message> getMessagesForEndDateId()
	{
		return this.messagesForEndDateId;
	}
	
	public void setMessagesForEndDateId(Set<Message> messagesForEndDateId)
	{
		this.messagesForEndDateId = messagesForEndDateId;
	}
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "date")
	public Set<Check> getChecks()
	{
		return this.checks;
	}
	
	public void setChecks(Set<Check> checks)
	{
		this.checks = checks;
	}
}
